<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.mongodb.client.MongoCursor,org.bson.Document" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加课程班</title>
<script>
	//表单提交前进行数据验证，数据合法则返回true表单提交
	function check(classform) {  
	    if(classform.coursecode.value=="") {  
	        swal("课程代码不能为空","请重新输入","warning");  
	        return false;  
	    }  
	    else if(!isNumber(classform.coursecode.value)) {
	    	swal("课程代码不合法","请重新输入","warning");  
	        return false;  
	    }
	    else if(classform.name.value=="") {  
	    	swal("课程名称不能为空","请重新输入","warning");   
	        return false;  
	    }  
	    else if(classform.class.value=="") {
	    	swal("教学班不能为空","请重新输入","warning");   
	        return false;  
	    }else if(classform.teachername.value=="") {
	    	swal("教师姓名不能为空","请重新输入","warning");   
	        return false;  
	    }else if(classform.teachercode.value=="") {
	    	swal("教师工号不能为空","请重新输入","warning");   
	        return false;  
	    } else if(!isNumber(classform.teachername.value)) {
	    	swal("教师工号不合法","请重新输入","warning");   
	        return false;  
	    }    

	    return true;  
	}   
	  
	function isNumber(str)          // 判断是否为非负整数  
	{  
	    var rx = /^[0-9]+$/;  
	    return rx.test(str);  
	} 
</script>
</head>
<body>
	<jsp:include page="navbar.jsp" />
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-1 col-md-offset-3">
				<a href="courseclassServlet?method=list">
					<button type="button" class="btn btn-default"><em class="fa fa-chevron-left"></em> 返回</button>
				</a>
			</div>
		</div>
    	<div class="row mt20">
			<div class="col-md-6 col-md-offset-3">
				<div class="panel">
                	<div class="panel-body">
                  		<h4 class="page-header mt0">添加课程班信息</h4>
                  			<form name="classform" role="form" action="courseclassServlet" method="post"  onsubmit="return check(this);" class="form-horizontal mt20">
	                  	    <fieldset>
				              <div class="form-group">
				                  <label class="col-md-3 control-label">课程代码</label>
				                  <div class="col-md-8">
				                     <input class="form-control" type="text" name="coursecode" placeholder="请输入课程代码" />
				                  </div>
				               </div> 
			                </fieldset>
		               		<fieldset>
			               		<div class="form-group">
			                  		<label class="col-md-3 control-label">课程名称</label>
		                  			<div class="col-md-8">
		                     			<input class="form-control" type="text" name="name" placeholder="请输入课程名称" />
		                  			</div>
		               			</div>	
		               		</fieldset>  
		               		<fieldset>
		               			 <div class="form-group">
					               <label class="col-sm-3 control-label">教学班</label>
					               <div class="col-sm-8">
					               	<input class="form-control" type="text" name="class" placeholder="请输入教学班" />
					              </div>
		               		</fieldset> 
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">教师姓名</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="teachername" placeholder="请输入教师姓名" />			     
			               			</div>
			               		</div>
		               		</fieldset>
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">教师工号</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="teachercode" placeholder="请输入教师工号" />		
			               			</div>
			               		</div>
		               		</fieldset>
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">教师职称</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="title" placeholder="请输入教师职称" />
			               			</div>
			               		</div>
		               		</fieldset>
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班人数</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="number" placeholder="请输入课程班人数" />
			               			</div>
			               		</div>
		               		</fieldset> 
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班考核方式</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="testtype" placeholder="请输入考核方式" />
			               			</div>
			               		</div>
		               		</fieldset>  
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班起止周</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="beginendweek" placeholder="请输入起止周" />
			               			</div>
			               		</div>
		               		</fieldset>
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班学时</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="studytime" placeholder="请输入学时" />
			               			</div>
			               		</div>
		               		</fieldset>
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班总学时</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="allstudytime" placeholder="请输入总学时" />
			               			</div>
			               		</div>
		               		</fieldset>		
		               		<fieldset>
			              		<div class="form-group mt15">
			               			<label class="col-md-3 control-label">课程班周学时</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="weekstudytime" placeholder="请输入周学时" />
			               			</div>
			               		</div>
		               		</fieldset>	
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班学分</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="credit" placeholder="请输入学分" />
			               			</div>
			               		</div>
		               		</fieldset>	
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班理论学时</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="theortytime" placeholder="请输入理论学时" />
			               			</div>
			               		</div>
		               		</fieldset>	
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-3 control-label">课程班实验学时</label>
				               		<div class="col-md-8">
				               			<input class="form-control" type="text" name="labtime" placeholder="请输入实验学时" />
			               			</div>
			               		</div>
		               		</fieldset>		               				               				               				               			               				               		 		               				               		 		               		      
		               		<input type="hidden" name="major" id="major">
		               		<div class="col-md-10 col-md-offset-1 mt20">
		               			<div class="col-md-6">
		               				<button type="submit" class="btn btn-primary btn-block" name="method" value="add">添加</button> 
		               			</div>
		               			<div class="col-md-6">
		               				<button type="reset" class="btn btn-default btn-block">重置</button> 
		               			</div>
		               		</div>
		               		
	              			</form>
               		</div>
            	</div>
         	</div>
       </div>
    </div>
</body>
</html>